<template>
	<view class="container">
		<TopBtn :title="'会诊详情'"></TopBtn>
		<view class="info">
			<view class="currency_card hzry">
				<view class="currency_title mb_30">
					会诊人员
					<small style="margin-left: 30rpx; color: #999; font-size: 14px; font-weight: normal">
						{{ data.groupId }}
					</small>
				</view>
				<view class="status flex-center-center">
					<text></text>
					{{ data.loginStatusName }}
				</view>
				<view class="currency_info doctorList">
					<view class="" v-for="n in data.doctorInfoRespVOList">
						<image :src="n.avatar" mode=""></image>
						<view class="name">
							{{ n.name }}
						</view>
						<view class="position">
							{{ n.role == 1 ? '医生' : '药师' }}
						</view>
					</view>
				</view>
			</view>
			<!-- <patientCard></patientCard> -->
			<view class="currency_card">
				<view class="currency_info">
					<view class="Card_row">
						<view class="title">患者：</view>
						<view class="">
							{{ data.patientName }}
							<!-- {{data.patientSex==1?'男':'女'}} -->
							<!-- {{patient.patientAge}}岁 -->
						</view>
					</view>
					<view class="Card_row">
						<view class="title">会诊时间：</view>
						<view class="">
							<uni-dateformat :date="data.consultationTime" format="yyyy-MM-dd hh:mm"></uni-dateformat>
						</view>
					</view>
					<view class="Card_row">
						<view class="title">会诊费用：</view>
						<view class="">￥{{ data.amount }}</view>
					</view>

					<view class="Card_row">
						<view class="title">简要病史：</view>
					</view>
					<view class="greyBg">
						{{ data.briefMedical }}
					</view>
					<view class="Card_row">
						<view class="title2">辅助检查结果：</view>
					</view>
					<view class="greyBg">
						{{ data.auxiliaryResult }}
					</view>
					<view class="Card_row">
						<view class="title">初步诊断：</view>
					</view>
					<view class="greyBg">
						{{ data.primaryDiagnosis }}
					</view>
					<view class="Card_row">
						<view class="title">邀请会诊目的：</view>
					</view>
					<view class="greyBg">
						{{ data.invitationPurpose }}
					</view>
				</view>
			</view>
			<!-- <view class="currency_card">
				<view class="currency_title">
					病情资料
				</view>
				<DiseaseCondition></DiseaseCondition>
			</view> -->
		</view>
		<view class="btnBoxTow" v-if="data.loginStatus === 2">
			<view class="cancel" @click="RejectpopupOpen()">拒诊</view>
			<view class="confirm" @click="receiveConsultationInfo()">接诊</view>
		</view>
		<uni-popup ref="Rejectpopup" type="bottom">
			<view class="pupbox">
				<view class="title">
					<view class="close" @click="pupclose()">取消</view>
					拒绝原因
					<view class="add" @click="hzrefuseOutpatientInfo()">确认</view>
				</view>
				<view class="">
					<textArea v-model="refuseReason" :inputNane="refuseReason" :maxNum="50"></textArea>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getConsultationInfo,
		receiveConsultationInfo,
		hzrefuseOutpatientInfo,
	} from '@/api/ConsultationRoom'

	export default {
		data() {
			return {
				data: {
					doctorInfoRespVOList: [],
				},
				id: '',
				refuseReason: '',
			}
		},
		onLoad(e) {
			this.id = e.id
			this.getConsultationInfo()
		},
		methods: {
			pupclose() {
				this.$refs.Rejectpopup.close()
			},
			hzrefuseOutpatientInfo() {
				if (!this.refuseReason) {
					uni.showToast({
						title: '请填写原因',
						duration: 2000,
						icon: 'none',
					})
					return
				}
				hzrefuseOutpatientInfo({
					id: this.id,
					status: '5',
					refuseReason: this.refuseReason,
				}).then(res => {
					uni.showToast({
						title: '操作成功',
						duration: 2000,
						icon: 'none',
					})
					this.getConsultationInfo(this.id)
					this.pupclose()
				})
			},
			RejectpopupOpen() {
				this.$refs.Rejectpopup.open('bottom')
			},
			receiveConsultationInfo() {
				var that = this
				uni.showModal({
					title: '提示',
					content: '是否确认接诊',
					success: res => {
						if (res.confirm) {
							receiveConsultationInfo({
								id: that.id,
							}).then(async res => {
								// 获取会诊详情
								that.getConsultationInfo()
							})
						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					},
				})
			},
			getConsultationInfo() {
				getConsultationInfo({
					id: this.id,
				}).then(res => {
					this.data = res.data
				})
			},
			async open() {},
		},
	}
</script>

<style lang="less">
	.pupbox {
		width: 750rpx;
		height: 522rpx;
		background: #ffffff;
		border-radius: 50rpx 50rpx 0rpx 0rpx;
		padding: 30rpx 50rpx;
		box-sizing: border-box;
		background-size: 100% 100%;

		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
			position: relative;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.add {
				font-weight: 500;
				font-size: 28rpx;
				color: #3e6efe;
			}

			.close {
				font-weight: 500;
				font-size: 28rpx;
				color: #999999;
			}
		}

		.messageList {
			margin-top: 1em;

			margin-top: 1em;

			.scroll-view_H {
				white-space: nowrap;
				width: 100%;
			}

			.messageinfo {
				display: inline-block;
				width: 287rpx;
				height: 220rpx;
				border: 2px solid #eeeeee;
				border-radius: 15rpx;
				margin-right: 25rpx;
				padding: 20rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				font-weight: 500;
				color: #999999;
				vertical-align: top;
			}

			.text {
				height: 100%;
				display: flex;
				align-items: center;
				white-space: wrap;
				white-space: pre-wrap;
				/* css-3 */
				white-space: -moz-pre-wrap;
				/* Mozilla, since 1999 */
				white-space: -pre-wrap;
				/* Opera 4-6 */
				white-space: -o-pre-wrap;
				/* Opera 7 */
				word-wrap: break-word;
				/* Internet Explorer 5.5+ */
			}

			.act {
				border: 4rpx solid #aa75fa;
				color: #7e67fd;
			}
		}

		// 多行文本输入框
		/deep/.uni-easyinput__content {
			border: none;
		}

		// 多行文本输入框
		/deep/.is-textarea {
			background-color: #f9f9f9 !important;
			margin: 23rpx 0 40rpx;
		}

		/deep/.is-input-border {
			border-radius: 20rpx;
		}

		/deep/.uni-easyinput__placeholder-class {
			font-size: 28rpx;
		}
	}

	.hzry {
		position: relative;

		.status {
			position: absolute;
			top: 0%;
			right: 0;
			width: 131rpx;
			height: 55rpx;
			background: #f9fbfe;
			border-radius: 20rpx;
			font-weight: 500;
			font-size: 28rpx;
			color: #3e6efe;

			text {
				display: inline-block;
				width: 16rpx;
				height: 16rpx;
				background: rgba(62, 110, 254, 0.22);
				border-radius: 50%;
				margin-right: 5rpx;
			}
		}
	}

	.greyBg {
		width: 649rpx;
		min-height: 72rpx;
		background: #fafafa;
		border-radius: 10rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #333333;
		padding: 29rpx 16rpx;
		box-sizing: border-box;
	}

	.info {
		padding: 30rpx;

		.doctorList {
			display: flex;
			flex-wrap: wrap;
			text-align: center;

			&>view {
				min-width: 100rpx;
				margin-right: 50rpx;

				.name {
					font-weight: 500;
					font-size: 28rpx;
					color: #333333;
				}

				.position {
					font-weight: 500;
					font-size: 24rpx;
					color: #999999;
				}
			}

			image {
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
			}
		}

		.currency_card {
			position: relative;

			.state {
				position: absolute;
				right: 0;
				top: 0;
				padding: 0 5rpx;
				min-width: 100rpx;
				height: 50rpx;
				background: #f9fbfe;
				font-size: 28rpx;
				color: #3e6efe;
				text-align: center;
				line-height: 50rpx;
				border-radius: 0 21rpx;
			}
		}

		&>view {
			margin-bottom: 27rpx;
		}

		.currency_info {
			margin-top: 21rpx;

			&:last-child {
				margin-top: 0rpx;
			}

			.Card_row {
				display: flex;
				font-weight: 500;
				font-size: 28rpx;
				color: #333;
				align-items: center;
				min-height: 50rpx;

				.title {
					width: 150rpx;
					color: #999;
				}

				.title2 {
					width: 300rpx;
					color: #999;
				}
			}
		}
	}
</style>